//
//  AY_SearchEmptyView.m
//  AiYue
//
//  Created by boWen on 2023/11/20.
//

#import "AY_SearchEmptyView.h"
#import "AY_BookQiuBookPage.h"
@interface AY_SearchEmptyView ()

@property (nonatomic, strong) UILabel * subTitleLbl;
@end

@implementation AY_SearchEmptyView


- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        UIView * bg_view1 = [AYTool createViewWithFrame:CGRectZero andBg:COLOR(@"#FBF2EF") andRadius:YNUM(6) andAddSubView:self];
        [bg_view1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(YNUM(3));
            make.left.equalTo(self);
            make.right.equalTo(self);
            make.height.offset(YNUM(45));
        }];
        UILabel * tips = [AYTool createLabelWithFrame:CGRectZero andText:@"注：请仔细核对书名或者主角是否正确，或者简化搜索关键词" andTextColor:COLOR(@"#FD8301") andBgColor:nil andFont:[UIFont systemFontOfSize:YNUM(12)] andLines:1 andRadius:0 andAddSubView:bg_view1];
        [tips mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bg_view1).offset(YNUM(8));
            make.right.equalTo(bg_view1).offset(YNUM(-8));
            make.centerY.equalTo(bg_view1);
        }];
        
        UIView * bg_view2 = [AYTool createViewWithFrame:CGRectZero andBg:COLOR_Bg andRadius:YNUM(6) andAddSubView:self];
        [bg_view2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(bg_view1.mas_bottom).offset(YNUM(15));
            make.left.equalTo(self);
            make.right.equalTo(self);
            make.height.offset(YNUM(93));
        }];
        
        UIImageView * leftImg = [AYTool createImageViewWithFrame:CGRectZero andImage:YImage(@"placeholderImage") andBg:nil andRadius:YNUM(4) andAddSubView:bg_view2];
        [leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(YNUM(93));
            make.width.mas_equalTo(YNUM(70));
            make.left.equalTo(bg_view2).offset(YNUM(15));
            make.top.equalTo(bg_view2);
        }];
        
        
       self.titleLabel = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:THEME_COLOR andBgColor:nil andFont:[UIFont boldSystemFontOfSize:YNUM(16)] andLines:1 andRadius:0 andAddSubView:bg_view2];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(leftImg.mas_top);
            make.left.equalTo(leftImg.mas_right).offset(YNUM(12));
            make.right.equalTo(bg_view2.mas_right).offset(YNUM(-12));
            make.height.mas_equalTo(YNUM(24));
        }];
        
        self.subTitleLbl = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:COLOR(@"#97A4B0") andBgColor:nil andFont:[UIFont boldSystemFontOfSize:YNUM(12)] andLines:2 andRadius:0 andAddSubView:bg_view2];
        [self.subTitleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).offset(YNUM(6));
            make.left.equalTo(self.titleLabel.mas_left);
            make.right.equalTo(bg_view2.mas_right).offset(YNUM(-10));
        }];
        
        
        UIView * downV = [AYTool createViewWithFrame:CGRectZero andBg:COLOR(@"#EFEFF9") andRadius:YNUM(6) andAddSubView:self];
        [downV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(leftImg.mas_bottom);
            make.left.equalTo(self.titleLabel.mas_left);
            make.height.mas_equalTo(YNUM(36));
        }];
        
        
        UIImageView * arrowImg = [AYTool createImageViewWithFrame:CGRectZero andImage:YImage(@"icon_rightArrow.png") andBg:nil andRadius:YNUM(4) andAddSubView:downV];
        [arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.mas_equalTo(YNUM(10));
            make.right.equalTo(downV).offset(YNUM(-12));
            make.centerY.equalTo(downV);
        }];
        
        UILabel * downLabel = [AYTool createLabelWithFrame:CGRectZero andText:@"填写详细信息最快当天可上架" andTextColor:THEME_COLOR andBgColor:COLOR(@"#EFEFF9") andFont:[UIFont boldSystemFontOfSize:YNUM(12)] andLines:1 andRadius:0 andAddSubView:downV];
        downLabel.textAlignment = NSTextAlignmentLeft;
        [downLabel sizeToFit];
        [downLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(downV);
            make.bottom.equalTo(downV);
            make.left.equalTo(downV.mas_left).offset(YNUM(12));
            make.right.equalTo(arrowImg.mas_left).offset(YNUM(-4));
        }];
        
        
        
        UIButton * towwerBtn = [AYTool createButtonWithFrame:CGRectZero andTitle:@"明天再来看看" andFont:[UIFont boldSystemFontOfSize:16] andTitleColor:[UIColor whiteColor] andBg:COLOR(@"#8690B3") andImage:nil andBgImage:nil andTarget:self andAction:@selector(handleTowwerAction) andRadius:YNUM(24) andAddSubView:self];
        [towwerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(bg_view2.mas_bottom).offset(YNUM(160));
            make.centerX.equalTo(self);
            make.width.mas_offset(YNUM(249));
            make.height.mas_offset(YNUM(48));
        }];
        
        
        UIButton * qiuBookBtn = [AYTool createButtonWithFrame:CGRectZero andTitle:@"立即在线求书" andFont:[UIFont boldSystemFontOfSize:16] andTitleColor:COLOR(@"#702E18") andBg:COLOR(@"#F3BDA9") andImage:nil andBgImage:nil andTarget:self andAction:@selector(handleQiuShuAction) andRadius:YNUM(24) andAddSubView:self];
        [qiuBookBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(towwerBtn.mas_bottom).offset(YNUM(26));
            make.centerX.equalTo(self);
            make.width.mas_offset(YNUM(249));
            make.height.mas_offset(YNUM(48));
        }];
        qiuBookBtn.backgroundColor = [AYTool customJianBianColorWithColor0:COLOR(@"#FFE1CA") withColor1:COLOR(@"#F3BDA9") withFrame:CGSizeMake(YNUM(249), YNUM(48)) withType:0];
        
        UIImageView * vpTipsImg = [AYTool createImageViewWithFrame:CGRectZero andImage:YImage(@"icon_qs_vp.png") andBg:nil andRadius:YNUM(4) andAddSubView:qiuBookBtn];
        [vpTipsImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(YNUM(24));
            make.width.mas_equalTo(YNUM(56));
            make.right.equalTo(qiuBookBtn).offset(YNUM(-5));
            make.top.equalTo(qiuBookBtn);
        }];
        
        
    }
    return self;
}

- (void)setConfigModel:(ConfigModel *)configModel {
    _configModel = configModel;
    self.subTitleLbl.text = configModel.search_tip;
}

#pragma mark - 明天再看看

- (void)handleTowwerAction {
    [[AYTool viewControllerWith:self].navigationController popToRootViewControllerAnimated:YES];
}


- (void)handleQiuShuAction {
    AY_BookQiuBookPage * page = [[AY_BookQiuBookPage alloc] init];
    page.bookName = self.titleLabel.text;
    [[AYTool viewControllerWith:self].navigationController pushViewController:page animated:YES];
}


@end
